<template>
  <el-dialog
    :model-value="modelValue"
    :title="title"
    width="600"
    draggable
    align-center
    @close="handleClose"
    :z-index="2000"
  >
    <template #default>
      <el-form
        ref="formRef"
        :model="model"
        :rules="rules"
        label-width="80"
        label-position="top"
      >
        <el-form-item label="审核">
          <el-radio-group v-model="model.operation">
            <el-radio :label="1">通过</el-radio>
            <el-radio :label="2">拒绝</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审核备注">
          <el-input
            v-model="model.remark"
            placeholder="请输入"
            :autosize="{ minRows: 4, maxRows: 10 }"
            type="textarea"
          />
        </el-form-item>
      </el-form>
    </template>
    <template #footer>
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" :loading="loading" @click="save">保 存</el-button>
    </template>
  </el-dialog>
</template>
<script setup>
import { ElMessage } from "element-plus";
const props = defineProps({
  modelValue: { type: Boolean, default: false },
  disabled: { type: Boolean, default: false },
  loading: { type: Boolean, default: false },
  title: { type: String, default: "审核" },
});
const rules = ref({});
const model = ref({});
const emit = defineEmits(["update:modelValue", "refresh", "close", "submit"]);
const formRef = ref();
const save = async () => {
  emit("submit", model.value);
};
const handleClose = async (refresh) => {
  model.value = {};
  await nextTick();
  emit("update:modelValue", false);
  emit("close");
  if (refresh) emit("refresh");
};
defineExpose({ open });
</script>
